<template>
    <el-dialog  :visible.sync="scoreVisible"  title="评分" width="30%" append-to-body>
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-form-item label="综合评分" prop="score">
          <el-rate v-model="formData.score"></el-rate>
        </el-form-item>
        <el-form-item label="评价" prop="appraise">
          <el-input v-model="formData.appraise" type="textarea" placeholder="请输入您的评价"
            :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="cancel">取消</el-button>
        <el-button type="primary" @click="handelConfirm">确定</el-button>
      </div>
    </el-dialog>
</template>
<script>
import {updateScore} from "@/api/business/score"
export default {
  data() {
    return {
      scoreVisible:false,
      formData: {
        id:undefined,
        score: undefined,
        appraise: undefined,
      },
      rules: {
        score: [{
          required: true,
          message: '综合评分不能为空',
          trigger: 'change'
        }],
        appraise: [{
          required: true,
          message: '请输入您的评价评价',
          trigger: 'blur'
        }],
      },
    }
  },
  methods: {
    init(id){
          this.formData.id = id;
          console.log(this.formData.id)
           this.scoreVisible = true;
      },
    cancel(){
          this.scoreVisible = false;
      },
    handelConfirm() {
        console.log(this.formData)
        updateScore(this.formData).then(response=>{
            this.msgSuccess("评价完成");
            this.formData = {
        id:undefined,
        score: undefined,
        appraise: undefined,
      }
            this.scoreVisible = false;
             this.$emit('changeShow')
        })
    },
  }
}

</script>
<style>
.el-rate {
  display: inline-block;
  vertical-align: text-top;
}

</style>
